import Axios from 'axios'

const state = {
	loading: [true],		//加载动画
	status: [],				//状态 1 == 会计科目  2 == 部门  3 == 职员  4 == 金额  5 == 审批步骤
	treeData: [],			//树形数据
	tableData: [],			//表格数据
	reviewerTableData: [],		//存放审核人表格数据
	treeNode: [],			//当前操作节点
	isAdd: [false],			//是否可以新增
	multipleSelection: [],	//选中的表格数据
	selectRowId: [],		//选中的表格数据id
	dfId: -1,				//默认全部节点的id
	dfName: '全部',			//默认全部节点的名称
	minMoney: 0,			//金额下限
	maxMoney: 50000000,		//金额上限
	billId: null,			//单据id
	vercharId: null,		//会计科目id
	deptId: null,			//部门id
	empId: null,			//职员id
	moneyId: null,			//金额id
	amounts: [],			//金额分段
	isExistAppvs: null,		//该条审批流程是否已存在
}

const mutations = {
	updateLoading(state, bool) {
		state.loading.splice(0, 1, bool);
	},
	updateStatus(state, n) {		//更新当前页面状态
		state.status.splice(0,1, n);
	},
	updateTreeData(state, arr) {		//更新树形结构数据
		if(Object.prototype.toString.call(arr) !== '[object Array]') return;
		let treeData = state.treeData;
		treeData.length = 0;
		if(arr.length > 0) {
			arr.forEach((item, index) => {
				item['level'] = 0;
				item['billId'] = item['id'];
				if(!item['subList']) item['subList'] = [];
				if(!item['children']) item['children'] = [
					{
						id: state.dfId,
						name: state.dfName,
						level: 1,
						billId: item['id'],
						pid: item['id'],
						children: [],
						subList: [
							{
								id: state.dfId,
								name: state.dfName,
								level: 2,
								parentId: 0,
								parentName: '无',
								billId: item['id'],
								pid: state.dfId,
								children: [],
								subList: [
									{
										id: state.dfId,
										name: state.dfName,
										level: 3,
										children: [],
										billId: item['id'],
										vercharId: state.dfId,
										pid: state.dfId,
										subList: [
											{
												id: state.dfId,
												name: state.minMoney + ' ~ ' + state.maxMoney,
												level: 4,
												money1: state.minMoney,
												money2: state.maxMoney,
												billId: item['id'],
												vercharId: state.dfId,
												deptId: state.dfId,
												pid: state.dfId,
												children: [],
												subList: []
											}
										]
									}
								]
							}
						]
					}
				];
			});
			treeData.splice(0, 1, ...arr);
		} else {
			treeData.splice(0);
		}
	},
	updateTableData(state, arr) {		//更新表格数据
		if(Object.prototype.toString.call(arr) !== '[object Array]') return;
		let tableData = state.tableData;
		tableData.length = 0;
		arr.length > 0 ? tableData.splice(0, 1, ...arr) : tableData.splice(0);
	},
	updateTreeNode(state, obj) {		//更新当前操作节点
		if(Object.prototype.toString.call(obj) !== '[object Object]') return;
		let treeNode = state.treeNode;
		treeNode.length = 0;
		obj ? treeNode.splice(0, 1, obj) : treeNode.splice(0);
	},
	updateIsAdd(state, bool) {
		state.isAdd.splice(0, 1, bool);
	},
	updateBillId(state, id) {			//更新单据id
		state.billId = (id || id === 0) ? id : null;
	},
	updateVercharId(state, id) {		//更新会计科目id
		state.vercharId = (id || id === 0) ? id : null;
	},
	updateDeptId(state, id) {			//更新部门id
		state.deptId = (id || id === 0) ? id : null;
	},
	updateEmpId(state, id) {			//更新职员id
		state.empId = (id || id === 0) ? id : null;
	},
	updateMoneyId(state, id) {			//更新金额id
		state.moneyId = (id || id === 0) ? id : null;
	},
	updateAmounts(state, val) {			//更新当前金额分段
		let amounts = state.amounts;
		val ? amounts.splice(0, 1, val) : amounts.splice(0);
	},
	updateIsExistAppvs(state, id) {		//更新已存在的审批流程id
		id ? state.isExistAppvs = id : state.isExistAppvs = null;
	},
	updateReviewerTableData(state, arr) {		//更新审核人表格数据
		if(Object.prototype.toString.call(arr) !== '[object Array]') return;
		let reviewerTableData = state.reviewerTableData;
		reviewerTableData.length = 0;
		reviewerTableData.splice(0, 1, ...arr);
	},
	appendNode(state, obj) {			//追加节点
		if(Object.prototype.toString.call(obj) !== '[object Object]') return;
		this.commit('verifyProcessStore/recursionAppendNode', {arr: state.treeData, obj: obj});
	},
	recursionAppendNode(state, obj) {			//递归新增节点
		if(Object.prototype.toString.call(obj) !== '[object Object]') return;
		let newObj = obj['obj'];
		obj['arr'].forEach(item => {
			if(item['level'] == state.treeNode[0]['level']) {
				if(item['$treeNodeId'] === state.treeNode[0]['$treeNodeId']) {
					switch(item['level']) {
						case 0:
							this.commit('verifyProcessStore/continueAppendRepeatData', {arr: item['children'], obj: newObj});
							this.commit('verifyProcessStore/updateTableData', item['children']);
							break;
						case 1:
							this.commit('verifyProcessStore/continueAppendRepeatData', {arr: item['subList'], obj: newObj});
							this.commit('verifyProcessStore/updateTableData', item['subList']);
							break;
						case 2:
							this.commit('verifyProcessStore/continueAppendRepeatData', {arr: item['subList'], obj: newObj});
							this.commit('verifyProcessStore/updateTableData', item['subList']);
							break;
						case 3:
							/*
							*	金额范围： 大于金额下限 ~ 小于等于金额上限
							*/
							if(item['subList'].length <= 1) {
								item['subList'].push(newObj);		//第一次允许新增
							} else {
								let flag = true;
								item['subList'].forEach(moneyItem => {
									if((newObj['money1'] == state.minMoney && newObj['money2'] == state.maxMoney)) {      //排除添加0 - 5000000
										flag = false;
										return false;
									} else {
										if(moneyItem['money1'] !== state.minMoney && (moneyItem['money2'] !== state.maxMoney)) {
											//如果输入金额在已存在的金额范围内，禁止添加
											if((newObj['money1'] >= moneyItem['money1'] || newObj['money2'] >= moneyItem['money1']) && (newObj['money1'] <= moneyItem['money2'] || newObj['money2'] <= moneyItem['money2'])) {
	                                            flag = false;
	                                            return false;
	                                        }
										}
									}
								});
								if(flag) item['subList'].push(newObj);
							}
							let newArr = item['subList'].sort((a, b) => a.money1 - b.money1);	//对金额进行大小排序
							this.commit('verifyProcessStore/updateTableData', newArr);
							break;
						case 4:
							//新增审核人
							item['subList'].push(newObj);
							this.commit('verifyProcessStore/updateReviewerTableData', item['subList']);
							break;
						default: break;
					}
				}
			} else {
				if(item['children'].length > 0) {
					this.commit('verifyProcessStore/recursionAppendNode', {arr: item['children'], obj: newObj});
				}
			}
		});
	},
	continueAppendRepeatData(state, obj) {			//终止重复添加数据
		let flag = true;
		obj['arr'].forEach(item => {
			if(item['id'] == obj['obj']['id']) {
				flag = false;
				return false;
			}
		});
		if(flag) obj['arr'].push(obj['obj']);
	},
	deleteNode(state, obj) {			//递归删除指定节点
    	let arr = obj['arr'];
    	obj['treeData'].forEach(treeItem => {
    		if(treeItem['level'] === Number(arr[0]['level'] - 1)) {
    			switch(Number(arr[0]['level'] - 1)) {
    				case 0:
    					//删除会计科目 单据id 必须一致
    					if(treeItem['id'] === arr[0]['pid']) {
    						this.commit('verifyProcessStore/deleteSelectNodes', {children: treeItem['children'], arr: arr});
    					}
    					break;
    				case 1:
    					//删除部门 单据id，会计科目id 都必须一致
    					if(treeItem['billId'] === arr[0]['billId'] && (treeItem['id'] === arr[0]['pid'])) {
    						this.commit('verifyProcessStore/deleteSelectNodes', {children: treeItem['subList'], arr: arr});
    					}
    					break;
    				case 2:
    					//删除职员 单据id，会计科目id，部门id 都必须一致
    					if(treeItem['billId'] === arr[0]['billId'] && (treeItem['pid'] === arr[0]['vercharId']) && (treeItem['id'] === arr[0]['pid'])) {
    						this.commit('verifyProcessStore/deleteSelectNodes', {children: treeItem['subList'], arr: arr});
    					}
    					break;
    				case 3:
    					//删除金额 单据id，会计科目id，部门id，职员id，都必须一致，然后根据分段金额去删除
    					if(treeItem['billId'] === arr[0]['billId'] && (treeItem['vercharId'] === arr[0]['vercharId']) && (treeItem['pid'] === arr[0]['deptId']) && (treeItem['id'] === arr[0]['pid'])) {
    						let children = treeItem['subList'];
    						if(children.length > 1) {
    							arr.forEach(subItem => {
    								children.forEach((treeSubItem, index) => {
    									if(subItem['money1'] !== state.minMoney && subItem['money2'] !== state.maxMoney) {
    										if(treeSubItem['money1'] === subItem['money1'] && treeSubItem['money2'] === subItem['money2']) {
    											children.splice(index, 1);
    										}
    									}
    								});
    							});
    							this.commit('verifyProcessStore/updateTableData', children);		//刷新表格数据
    						}
    					}
    					break;
    				default: break;
    			}
    		} else {
    			if(treeItem['children'].length > 0) {
    				this.commit('verifyProcessStore/deleteNode', {arr: arr, treeData: treeItem['children']});
    			}
    		}
    	});
    },
    deleteSelectNodes(state, obj) {
    	let children = obj['children'];
    	if(children.length > 1) {
    		obj['arr'].forEach(item => {
    			children.forEach((treeItem, index) => {
    				if(item['id'] === treeItem['id'] && (item['id'] !== state.dfId)) {
    					children.splice(index, 1);
    				}
    			});
    		});
    		this.commit('verifyProcessStore/updateTableData', children);		//刷新表格数据
    	}
    },
	multipleSelection(state, arr) {			//表格选中数据触发该函数
        state.multipleSelection.length = 0;
        state.selectRowId.length = 0;
        if(arr.length > 0) {
            arr.forEach(item => {
                state.multipleSelection.push(item);
                state.selectRowId.push(item['id']);
            });
        } else {
            state.multipleSelection.splice(0);
            state.selectRowId.splice(0);
        }
    },
    updateTreeDataByBills(state, arr) {		//根据后台返回的审批流程数据，更新树节点数据
    	if(Object.prototype.toString.call(arr) !== '[object Array]') return;
    	let treeData = state.treeData,
    		mn = null,
    		rowIndex = null,
    		approversData = [];		//存在（审核人 + 知会人 + 抄送人）
    	arr.forEach(item => {
    		//组装单据数据
    		if(item['bills'].length > 0) {
    			item['bills'][0]['level'] = 0;
    			item['bills'][0]['billId'] = item['bills'][0]['id'];
    			item['bills'][0]['subList'] = []; 
    			item['bills'][0]['children'] = [];
    		}
    		//组装会计科目数据
    		if(item['verchars'].length > 0) {
    			let verchars = item['verchars'][0];
    			if(verchars['id'] === state.dfId) {		//如果是默认全部节点，加上自定义数据
    				verchars['name'] = state.dfName;
    			}
    			verchars['level'] = 1;
    			verchars['billId'] = item['bills'][0]['id'];
    			verchars['pid'] = item['bills'][0]['id'];
    			verchars['children'] = [];
    			verchars['subList'] = [];
    		}
    		//组装部门数据
    		if(item['departments'].length > 0) {
    			let departments = item['departments'][0];
    			if(departments['id'] === state.dfId) {		//如果是默认全部节点，加上自定义数据
    				departments['name'] = state.dfName;
    				departments['parentId'] = 0;
    				departments['parentName'] = '无';
    			}
    			departments['level'] = 2;
    			departments['billId'] = item['bills'][0]['id'];
    			departments['pid'] = item['verchars'][0]['id'];
    			departments['children'] = [];
    			departments['subList'] = [];
    		}
    		//组装职员数据
    		if(item['employees'].length > 0) {
    			let employees = item['employees'][0];
    			delete employees['moneyNumber'];
    			if(employees['id'] === state.dfId) {
    				employees['name'] = state.dfName;
    			}
    			employees['level'] = 3;
    			employees['children'] = [];
    			employees['billId'] = item['bills'][0]['id'];
    			employees['vercharId'] = item['verchars'][0]['id'];
    			employees['pid'] = item['departments'][0]['id'];
    			employees['subList'] = [];
    		}
    		//组装金额数据
    		if(item['moneys'].length > 0) {
    			let moneys = item['moneys'][0];
    			mn = moneys['name'].split(',');
    			moneys['id'] = state.dfId;
    			moneys['name'] = mn[0] + ' ~ ' + mn[1];
    			moneys['level'] = 4;
    			moneys['money1'] = Number(mn[0]);
    			moneys['money2'] = Number(mn[1]);
    			moneys['billId'] = item['bills'][0]['id'];
    			moneys['vercharId'] = item['verchars'][0]['id'];
    			moneys['deptId'] = item['departments'][0]['id'];
    			moneys['pid'] = item['employees'][0]['id'];
    			moneys['children'] = [];
    			moneys['subList'] = [];
    		}
    		//组装审核人
    		if(item['approvers'].length > 0) {
    			mn = item['moneys'][0];
    			item['approvers'].forEach(approverItem => {
    				approverItem['billId'] = item['bills'][0]['id'];
	    			approverItem['vercharId'] = item['verchars'][0]['id'];
	    			approverItem['deptId'] = item['departments'][0]['id'];
	    			approverItem['empId'] = item['employees'][0]['id'];
	    			approverItem['pid'] = state.dfId;
	    			approverItem['money1'] = mn['money1'];
	    			approverItem['money2'] = mn['money2'];
    			});
    		}
    		//组装知会人
			if(item['notifyPeoples'].length > 0) {
				mn = item['moneys'][0];
    			item['notifyPeoples'].forEach(notifyPeopleItem => {
    				notifyPeopleItem['billId'] = item['bills'][0]['id'];
	    			notifyPeopleItem['vercharId'] = item['verchars'][0]['id'];
	    			notifyPeopleItem['deptId'] = item['departments'][0]['id'];
	    			notifyPeopleItem['empId'] = item['employees'][0]['id'];
	    			notifyPeopleItem['pid'] = state.dfId;
	    			notifyPeopleItem['money1'] = mn['money1'];
	    			notifyPeopleItem['money2'] = mn['money2'];
    			});
    		}
    		//组装抄送人
    		if(item['copyPeoples'].length > 0) {
    			mn = item['moneys'][0];
    			item['copyPeoples'].forEach(copyPeopleItem => {
    				copyPeopleItem['billId'] = item['bills'][0]['id'];
	    			copyPeopleItem['vercharId'] = item['verchars'][0]['id'];
	    			copyPeopleItem['deptId'] = item['departments'][0]['id'];
	    			copyPeopleItem['empId'] = item['employees'][0]['id'];
	    			copyPeopleItem['pid'] = state.dfId;
	    			copyPeopleItem['money1'] = mn['money1'];
	    			copyPeopleItem['money2'] = mn['money2'];
    			});
    		}
    		approversData = approversData.concat(item['approvers'], item['notifyPeoples'], item['copyPeoples']);
    		rowIndex = Math.max.apply(Math, approversData.map(rowItem => rowItem['serialNumber']));      //取得最大行数
    		item['approversData'] = approversData;
    		item['rowIndex'] = rowIndex;
    		treeData.forEach(treeItem => {
    			if(treeItem['id'] === item['bills'][0]['id']) {
    				this.commit('verifyProcessStore/renderVerchars', {parentNode: treeItem, data: item});	//渲染对应节点的会计科目数据
    			}
    		});
    	});
    },
    renderVerchars(state, obj) {		//渲染会计科目数据
    	let parentNode = obj['parentNode'],
    		data = obj['data'],
    		verchars = data['verchars'][0];
    	//保证(单据id)一致
    	if(verchars['pid'] === parentNode['id']) {
    		let flag = true;
    		if(parentNode['children'].length > 0) {
    			parentNode['children'].forEach(treeItem => {
    				if(treeItem['id'] === verchars['id']) {
    					flag = false;
    					return false;
    				}
    			});
    			if(flag) {
    				parentNode['children'].push(verchars);
    			}
    		} else {
    			parentNode['children'].push(verchars);
    		}
    		this.commit('verifyProcessStore/renderDepartments', {parentNode: parentNode['children'], data: data});
    	}
    },
    renderDepartments(state, obj) {		//渲染部门数据
    	let parentNode = obj['parentNode'],
    		data = obj['data'],
    		departments = data['departments'][0];
    	parentNode.forEach(vercharItem => {
    		//保证(单据id),(会计科目id)一致
    		if(departments['billId'] === vercharItem['billId'] && departments['pid'] === vercharItem['id']) {
    			//设置默认节点
    			let dfNode = {
    				id: state.dfId,
					name: state.dfName,
					level: 2,
					parentId: 0,
					parentName: '无',
					billId: data['bills'][0]['id'],
					pid: data['verchars'][0]['id'],
					children: [],
					subList: [
						{
							id: state.dfId,
							name: state.dfName,
							level: 3,
							children: [],
							billId: vercharItem['billId'],
							vercharId: vercharItem['id'],
							pid: state.dfId,
							subList: [
								{
									id: state.dfId,
									name: state.minMoney + ' ~ ' + state.maxMoney,
									level: 4,
									money1: state.minMoney,
									money2: state.maxMoney,
									billId: vercharItem['billId'],
									vercharId: vercharItem['id'],
									deptId: state.dfId,
									pid: state.dfId,
									children: [],
									subList: []
								}
							]
						}
					]
    			}
    			if(vercharItem['subList'].length > 0) {
    				let flag = true;
    				vercharItem['subList'].forEach(dpItem => {
    					if(dpItem['id'] === departments['id']) {
    						flag = false;
    						return false;
    					}
    				});
    				if(flag) vercharItem['subList'].push(departments);
    			} else {
    				vercharItem['subList'].push(dfNode,departments);
    			}
    			this.commit('verifyProcessStore/renderEmployees', {parentNode: vercharItem['subList'], data: data});
    		}
    	});
    },
    renderEmployees(state, obj) {		//渲染职员
    	let parentNode = obj['parentNode'],
    		data = obj['data'],
    		employees = data['employees'][0];
    	parentNode.forEach(dpItem => {
    		//保证(单据id),(会计科目id),(部门id)都一致
    		if(employees['billId'] === dpItem['billId'] && employees['vercharId'] === dpItem['pid'] && employees['pid'] === dpItem['id']) {
    			//设置默认节点
    			let dfNode = {
    				id: state.dfId,
					name: state.dfName,
					level: 3,
					children: [],
					billId: dpItem['billId'],
					vercharId: dpItem['pid'],
					pid: dpItem['id'],
					subList: [
						{
							id: state.dfId,
							name: state.minMoney + ' ~ ' + state.maxMoney,
							level: 4,
							money1: state.minMoney,
							money2: state.maxMoney,
							billId: dpItem['billId'],
							vercharId: dpItem['pid'],
							deptId: dpItem['id'],
							pid: state.dfId,
							children: [],
							subList: []
						}
					]
    			}
    			if(dpItem['subList'].length > 0) {
    				let flag = true;
    				dpItem['subList'].forEach(empItem => {
    					if(empItem['id'] === employees['id']) {
    						flag = false;
    						return false;
    					}
    				});
    				if(flag) dpItem['subList'].push(employees);
    			} else {
    				dpItem['subList'].push(employees);
    				dpItem['subList'].forEach(empItem => {
    					if(empItem['id'] !== state.dfId) {
    						dpItem['subList'].unshift(dfNode);
    					}
    				});
    			}
    			this.commit('verifyProcessStore/renderMoneys', {parentNode: dpItem['subList'], data: data});
    		}
    	});
    },
    renderMoneys(state, obj) {			//渲染金额
    	let parentNode = obj['parentNode'],
    		data = obj['data'],
    		moneys = data['moneys'][0];
    	parentNode.forEach(empItem => {
    		//保证(单据id),(会计科目id),(部门id),(职员id)都一致
    		if(moneys['billId'] === empItem['billId'] && moneys['vercharId'] === empItem['vercharId'] && moneys['deptId'] === empItem['pid'] && moneys['pid'] === empItem['id']) {
    			let dfNode = {
    				id: state.dfId,
					name: state.minMoney + ' ~ ' + state.maxMoney,
					level: 4,
					money1: state.minMoney,
					money2: state.maxMoney,
					billId: empItem['billId'],
					vercharId: empItem['vercharId'],
					deptId: empItem['pid'],
					pid: empItem['id'],
					children: [],
					subList: []
    			}
    			if(empItem['subList'].length > 0) {
    				let flag = true;
    				empItem['subList'].forEach(moneyItem => {
    					if(moneyItem['id'] === moneys['id']) {
    						flag = false;
    						return false;
    					}
    				});
    				if(flag) empItem['subList'].push(moneys);
    			} else {
    				empItem['subList'].push(moneys);
    				empItem['subList'].forEach(moneyItem => {
    					if(moneyItem['money1'] !== state.minMoney && moneyItem['money2'] !== state.maxMoney) {
    						empItem['subList'].unshift(dfNode);
    					}
    				});
    			}
    			this.commit('verifyProcessStore/renderApprover', {parentNode: empItem['subList'], data: data});
    		}
    	});
    },
    renderApprover(state, obj) {		//渲染审核人
    	let parentNode = obj['parentNode'],
    		data = obj['data'],
    		approverData = [].concat(data['approvers'], data['notifyPeoples'], data['copyPeoples']),	//将每条审批流程的(审核，知会，抄送)节点合为一起
    		maxRowNumber = Math.max.apply(Math, approverData.map(rowItem => rowItem['serialNumber'])),  //取得每条审批流程所有节点的最大行数
    		tableData = null,
    		nameArray = ['name', 'name1', 'name2', 'name3'];
    	//根据serialNumber行号进行归类，返回一个新数组
    	let classifyByAttr = function(array) {
    		let newArr = [],
    			newObj = {};
    		array.forEach(element => {
    			if(!newObj[element.serialNumber]) {
    				newArr.push({
			           	serialNumber: element.serialNumber,
			            allData: [element]
			        });
			        newObj[element.serialNumber] = element;
    			} else {
    				newArr.forEach(ele => {
			            if(ele.serialNumber == element.serialNumber){
			                ele.allData.push(element);
			            }
			        });
    			}
    		});
    		return newArr;
    	}
    	let newApprover = classifyByAttr(data['approvers']);
    	let newNotifyPeople = classifyByAttr(data['notifyPeoples']);
    	let newCopyPeople = classifyByAttr(data['copyPeoples']);
    	//遍历行号，根据行号去创建表格数据
    	for(let i = 1; i <= maxRowNumber; i++) {
			tableData = {
				name: null,
				name1: null,
				name2: null,
				name3: null,
				level: 5,
				nodeType: null,
				generateDocument: null
			}
			let appendData = function(arr, nodeType) {
				arr.forEach(item => {
					if(item['serialNumber'] === i) {
						tableData['nodeType'] = nodeType;
						let allData = item['allData'];
						tableData['generateDocument'] = !Number(allData[0]['generateBill']);
						nameArray.forEach((attr, index) => allData[index] && (tableData[attr] = allData[index]['id']));
						parentNode.forEach(moneyItem => {
							if(allData[0]['billId'] === moneyItem['billId'] && allData[0]['vercharId'] === moneyItem['vercharId'] && allData[0]['deptId'] === moneyItem['deptId'] && allData[0]['empId'] === moneyItem['pid'] && (allData[0]['money1'] === moneyItem['money1'] && allData[0]['money2'] === moneyItem['money2'])) {
								moneyItem['subList'].push(tableData);
							}
						});
					}
				});
			}
			appendData(newApprover, 0);
			appendData(newNotifyPeople, 1);
			appendData(newCopyPeople, 2);
		}
    }
}

const actions = {
	getTreeData({commit, rootState}) {		//获取树形结构数据与审批流程数据
		commit('updateLoading', true);
		Axios.all([Axios.get('activiti/selectBills'), Axios.get('activiti/selectActiviti')]).then(Axios.spread((bills, activiti) => {
			if(bills.data.code == 20001 && activiti.data.code == 20001) {
				setTimeout(() => {
					commit('updateLoading', false);
					if(bills.data.data) {
						commit('updateStatus', '1');		//初始化为会计科目页面
						commit('updateTreeNode', bills.data.data[0]);		//treeNode默认为第一个节点数据
						commit('updateTreeData', bills.data.data);			//更新树形单据数据
					}
					if(activiti.data.data && activiti.data.data.length > 0) {
						commit('updateTreeDataByBills', activiti.data.data);		//更新审批流程数据
					}
				}, 200);
			} else {
				setTimeout(() => {
					commit('updateLoading', false);
				}, 200);
			}
		}));
	}
}


export default {
	namespaced: true,
	state,
	mutations,
	actions
}